import pandas
import os
class Use_data():
    def __init__(self,filename :str):
        dir1=os.path.dirname(__file__)
        dir2=os.path.dirname(dir1)
        data_path=os.path.join(dir2,'data')
        self.path=os.path.join(data_path,filename)
        if filename.endswith('.xls') or filename.endswith('.xlsx'):
            self.table=pandas.read_excel(self.path,keep_default_na=False)
        elif filename.endswith('.csv'):
            self.table=pandas.read_csv(self.path,keep_default_na=False)
    def data_list(self):
        return self.table.values.tolist()
    def data_dict(self):
        return [self.table.loc[i].to_dict() for i in self.table.index.values]
if __name__ == '__main__':
    # gCO = Use_data('generateConfirmOrder_data.csv').data_list()
    # print(gCO)
    gO = Use_data('generateOrder_data.csv').data_list()
    print(gO)
